package com.soulkun.smarthome.ui.main.home.manager

import android.app.Activity
import com.journeyapps.barcodescanner.BarcodeResult
import com.journeyapps.barcodescanner.CaptureManager
import com.journeyapps.barcodescanner.DecoratedBarcodeView

class SoulkunCaptureManager(activity: Activity, private val barcodeView: DecoratedBarcodeView): CaptureManager(activity, barcodeView) {

    private var onReturnResultListener: ((String) -> Unit)? = null

    fun setOnReturnResultListener(listener: (String) -> Unit) {
        onReturnResultListener = listener
    }

    override fun returnResult(rawResult: BarcodeResult) {
        if (onReturnResultListener != null) {
            onReturnResultListener!!(rawResult.result.text)
        }else{
            super.returnResult(rawResult)
        }
    }

}